﻿@using CollegeShop.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "NewManager";
    Layout = "~/Views/Shared/_Admin.cshtml";
}
<div class="main-content" style="margin-left: 190px; min-height: 575px;">
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li><i class="icon-home home-icon"></i><a href="/admin/index">Dashboard</a> </li>
            <li><a href="javascript:;">用户管理</a></li>
            <li class="active">新增管理员</li>
        </ul>
        <!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <div class="row-fluid">
            <div class="span7">
                <h3 class="row-fluid header smaller lighter purple">
                    <span class="span12">新增管理员</span>
                    <!-- /span -->
                </h3>
                <div class="span12">
                    <form id="regform" class="form-horizontal" action="/admin/NewManager" method="post">
                        <div class="control-group">
                            <label class="control-label">账户名</label>
                            <div class="controls">
                              <input id="txtuserName" type="text" class="input-xlarge {required:true,normalchar:true,remote:{url:'/account/usernameonly',messages:'该用户已存在'}}" 
                                 name="userName" placeholder="账户名" />
                            </div>
                         </div>
                         <div class="control-group">
                            <label class="control-label">密码</label>
                            <div class="controls">
                              <input id="txtpwd" type="password" class="input-xlarge {required:true,minlength:6,maxlength:12}" 
                                 name="password" />
                            </div>
                         </div>
                         <div class="control-group">
                            <label class="control-label">确认密码</label>
                            <div class="controls">
                              <input id="txtpwdconfirm" type="password" class="input-xlarge {required:true,equalTo:'#txtpwd'}"  />
                            </div>
                         </div>
                         <div class="control-group">
                            <label class="control-label">真实姓名</label>
                            <div class="controls">
                              <input id="txtnickName" type="text" name="NickName" class="input-xlarge {required:true,cn:true}"  />
                            </div>
                         </div>
                         <div class="control-group">
                            <label class="control-label">联系电话</label>
                            <div class="controls">
                              <input id="txtphone" type="text" name="Phone" class="input-xlarge" class="{required:true}" />
                            </div>
                         </div>
                         <div class="control-group">
                            <label class="control-label">角色</label>
                            <div class="controls">
                              <select name="SystemRole" id="sltSystemRole">
                                <option selected="selected" value="2">楼栋（销售单元）销售</option>
                                <option value="3">区域销售主管</option>
                                <option value="4">校区经理</option>
                              </select>
                            </div>
                         </div>
                         <div class="form-actions">
                            <button class="btn btn-primary" type="submit">
								<i class="icon-ok bigger-110"></i>
								完成
							</button>
                            <button class="btn" type="reset">
							    <i class="icon-undo bigger-110"></i>
							    重置
						    </button>
                         </div>
                    </form>
                </div>
            </div>
            <div class="span5">
                <h3 class="row-fluid header smaller lighter purple">
                    <span class="span12">现有管理员</span>
                </h3>
                <div class="span12">
                    <ol class="dd-list">
                    @{
                        Dictionary<int, List<CollegeShop.Infrastructure.Entities.Entity.User>> list = ViewBag.Staffs;
                        if (list != null && list.Any())
                        {
                            foreach(var item in list)
                            {
                                foreach(var g in item.Value)
                                {
                                    <li class="dd-item dd2-item">
                                        <div class="dd-handle dd2-handle">
                                            <i class="normal-icon icon-user red bigger-130"></i><i class="drag-icon icon-move bigger-125">
                                            </i>
                                        </div>
                                        <div class="dd2-content">
                                            @g.NickName (@g.UserName) - 
                                            @if(g.SystemRole == SystemRole.Staff)
                                            {
                                                if(g.SalesUnit != null){
                                                @g.SalesUnit.SalesUnitName@:销售主管
                                                }
                                                else
                                                {
                                                    @g.SystemRole.Mapping() @:(空置)
                                                }
                                            }
                                            else
                                            {
                                                @(g.SystemRole.Mapping())
                                            }</div>
                                    </li>
                                }
                            }
                        }
                        }
                    </ol>

                </div>
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript" src="/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/scripts/jquery.metadata.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#userBlock').trigger('click');
            $('#regform').validate({
                errorClass: "help-inline",
                errorElement: "span",
                highlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').addClass('error');
                },
                unhighlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').removeClass('error');
                }
            });
        });
    </script>
}
